<?php


/**
 * Base class that represents a query for the 'users' table.
 *
 *
 *
 * @method DamagesUsersQuery orderById($order = Criteria::ASC) Order by the id column
 * @method DamagesUsersQuery orderByPermissionId($order = Criteria::ASC) Order by the permission_id column
 * @method DamagesUsersQuery orderByEmail($order = Criteria::ASC) Order by the email column
 * @method DamagesUsersQuery orderByFirstName($order = Criteria::ASC) Order by the first_name column
 * @method DamagesUsersQuery orderByLastName($order = Criteria::ASC) Order by the last_name column
 * @method DamagesUsersQuery orderByPosition($order = Criteria::ASC) Order by the position column
 * @method DamagesUsersQuery orderByPhone($order = Criteria::ASC) Order by the phone column
 * @method DamagesUsersQuery orderByPhoneMobile($order = Criteria::ASC) Order by the phone_mobile column
 * @method DamagesUsersQuery orderByPhoneFax($order = Criteria::ASC) Order by the phone_fax column
 * @method DamagesUsersQuery orderByPassword($order = Criteria::ASC) Order by the password column
 * @method DamagesUsersQuery orderByForcePasswordChange($order = Criteria::ASC) Order by the force_password_change column
 * @method DamagesUsersQuery orderByCreated($order = Criteria::ASC) Order by the created column
 * @method DamagesUsersQuery orderByModified($order = Criteria::ASC) Order by the modified column
 *
 * @method DamagesUsersQuery groupById() Group by the id column
 * @method DamagesUsersQuery groupByPermissionId() Group by the permission_id column
 * @method DamagesUsersQuery groupByEmail() Group by the email column
 * @method DamagesUsersQuery groupByFirstName() Group by the first_name column
 * @method DamagesUsersQuery groupByLastName() Group by the last_name column
 * @method DamagesUsersQuery groupByPosition() Group by the position column
 * @method DamagesUsersQuery groupByPhone() Group by the phone column
 * @method DamagesUsersQuery groupByPhoneMobile() Group by the phone_mobile column
 * @method DamagesUsersQuery groupByPhoneFax() Group by the phone_fax column
 * @method DamagesUsersQuery groupByPassword() Group by the password column
 * @method DamagesUsersQuery groupByForcePasswordChange() Group by the force_password_change column
 * @method DamagesUsersQuery groupByCreated() Group by the created column
 * @method DamagesUsersQuery groupByModified() Group by the modified column
 *
 * @method DamagesUsersQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
 * @method DamagesUsersQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
 * @method DamagesUsersQuery innerJoin($relation) Adds a INNER JOIN clause to the query
 *
 * @method DamagesUsersQuery leftJoinPermissions($relationAlias = null) Adds a LEFT JOIN clause to the query using the Permissions relation
 * @method DamagesUsersQuery rightJoinPermissions($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Permissions relation
 * @method DamagesUsersQuery innerJoinPermissions($relationAlias = null) Adds a INNER JOIN clause to the query using the Permissions relation
 *
 * @method DamagesUsersQuery leftJoinSessions($relationAlias = null) Adds a LEFT JOIN clause to the query using the Sessions relation
 * @method DamagesUsersQuery rightJoinSessions($relationAlias = null) Adds a RIGHT JOIN clause to the query using the Sessions relation
 * @method DamagesUsersQuery innerJoinSessions($relationAlias = null) Adds a INNER JOIN clause to the query using the Sessions relation
 *
 * @method DamagesUsersQuery leftJoinCarDamagesRelatedByLsId($relationAlias = null) Adds a LEFT JOIN clause to the query using the CarDamagesRelatedByLsId relation
 * @method DamagesUsersQuery rightJoinCarDamagesRelatedByLsId($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CarDamagesRelatedByLsId relation
 * @method DamagesUsersQuery innerJoinCarDamagesRelatedByLsId($relationAlias = null) Adds a INNER JOIN clause to the query using the CarDamagesRelatedByLsId relation
 *
 * @method DamagesUsersQuery leftJoinCarDamagesRelatedByOlId($relationAlias = null) Adds a LEFT JOIN clause to the query using the CarDamagesRelatedByOlId relation
 * @method DamagesUsersQuery rightJoinCarDamagesRelatedByOlId($relationAlias = null) Adds a RIGHT JOIN clause to the query using the CarDamagesRelatedByOlId relation
 * @method DamagesUsersQuery innerJoinCarDamagesRelatedByOlId($relationAlias = null) Adds a INNER JOIN clause to the query using the CarDamagesRelatedByOlId relation
 *
 * @method DamagesUsersQuery leftJoinUserDealers($relationAlias = null) Adds a LEFT JOIN clause to the query using the UserDealers relation
 * @method DamagesUsersQuery rightJoinUserDealers($relationAlias = null) Adds a RIGHT JOIN clause to the query using the UserDealers relation
 * @method DamagesUsersQuery innerJoinUserDealers($relationAlias = null) Adds a INNER JOIN clause to the query using the UserDealers relation
 *
 * @method DamagesUsers findOne(PropelPDO $con = null) Return the first DamagesUsers matching the query
 * @method DamagesUsers findOneOrCreate(PropelPDO $con = null) Return the first DamagesUsers matching the query, or a new DamagesUsers object populated from the query conditions when no match is found
 *
 * @method DamagesUsers findOneById(int $id) Return the first DamagesUsers filtered by the id column
 * @method DamagesUsers findOneByPermissionId(int $permission_id) Return the first DamagesUsers filtered by the permission_id column
 * @method DamagesUsers findOneByEmail(string $email) Return the first DamagesUsers filtered by the email column
 * @method DamagesUsers findOneByFirstName(string $first_name) Return the first DamagesUsers filtered by the first_name column
 * @method DamagesUsers findOneByLastName(string $last_name) Return the first DamagesUsers filtered by the last_name column
 * @method DamagesUsers findOneByPosition(string $position) Return the first DamagesUsers filtered by the position column
 * @method DamagesUsers findOneByPhone(string $phone) Return the first DamagesUsers filtered by the phone column
 * @method DamagesUsers findOneByPhoneMobile(string $phone_mobile) Return the first DamagesUsers filtered by the phone_mobile column
 * @method DamagesUsers findOneByPhoneFax(string $phone_fax) Return the first DamagesUsers filtered by the phone_fax column
 * @method DamagesUsers findOneByPassword(string $password) Return the first DamagesUsers filtered by the password column
 * @method DamagesUsers findOneByForcePasswordChange(int $force_password_change) Return the first DamagesUsers filtered by the force_password_change column
 * @method DamagesUsers findOneByCreated(string $created) Return the first DamagesUsers filtered by the created column
 * @method DamagesUsers findOneByModified(string $modified) Return the first DamagesUsers filtered by the modified column
 *
 * @method array findById(int $id) Return DamagesUsers objects filtered by the id column
 * @method array findByPermissionId(int $permission_id) Return DamagesUsers objects filtered by the permission_id column
 * @method array findByEmail(string $email) Return DamagesUsers objects filtered by the email column
 * @method array findByFirstName(string $first_name) Return DamagesUsers objects filtered by the first_name column
 * @method array findByLastName(string $last_name) Return DamagesUsers objects filtered by the last_name column
 * @method array findByPosition(string $position) Return DamagesUsers objects filtered by the position column
 * @method array findByPhone(string $phone) Return DamagesUsers objects filtered by the phone column
 * @method array findByPhoneMobile(string $phone_mobile) Return DamagesUsers objects filtered by the phone_mobile column
 * @method array findByPhoneFax(string $phone_fax) Return DamagesUsers objects filtered by the phone_fax column
 * @method array findByPassword(string $password) Return DamagesUsers objects filtered by the password column
 * @method array findByForcePasswordChange(int $force_password_change) Return DamagesUsers objects filtered by the force_password_change column
 * @method array findByCreated(string $created) Return DamagesUsers objects filtered by the created column
 * @method array findByModified(string $modified) Return DamagesUsers objects filtered by the modified column
 *
 * @package    propel.generator.damages.om
 */
abstract class DamagesBaseUsersQuery extends ModelCriteria
{
    /**
     * Initializes internal state of DamagesBaseUsersQuery object.
     *
     * @param     string $dbName The dabase name
     * @param     string $modelName The phpName of a model, e.g. 'Book'
     * @param     string $modelAlias The alias for the model in this query, e.g. 'b'
     */
    public function __construct($dbName = 'vgp_damages', $modelName = 'DamagesUsers', $modelAlias = null)
    {
        parent::__construct($dbName, $modelName, $modelAlias);
    }

    /**
     * Returns a new DamagesUsersQuery object.
     *
     * @param     string $modelAlias The alias of a model in the query
     * @param     DamagesUsersQuery|Criteria $criteria Optional Criteria to build the query from
     *
     * @return DamagesUsersQuery
     */
    public static function create($modelAlias = null, $criteria = null)
    {
        if ($criteria instanceof DamagesUsersQuery) {
            return $criteria;
        }
        $query = new DamagesUsersQuery();
        if (null !== $modelAlias) {
            $query->setModelAlias($modelAlias);
        }
        if ($criteria instanceof Criteria) {
            $query->mergeWith($criteria);
        }

        return $query;
    }

    /**
     * Find object by primary key.
     * Propel uses the instance pool to skip the database if the object exists.
     * Go fast if the query is untouched.
     *
     * <code>
     * $obj  = $c->findPk(12, $con);
     * </code>
     *
     * @param mixed $key Primary key to use for the query
     * @param     PropelPDO $con an optional connection object
     *
     * @return   DamagesUsers|DamagesUsers[]|mixed the result, formatted by the current formatter
     */
    public function findPk($key, $con = null)
    {
        if ($key === null) {
            return null;
        }
        if ((null !== ($obj = DamagesUsersPeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
            // the object is alredy in the instance pool
            return $obj;
        }
        if ($con === null) {
            $con = Propel::getConnection(DamagesUsersPeer::DATABASE_NAME, Propel::CONNECTION_READ);
        }
        $this->basePreSelect($con);
        if ($this->formatter || $this->modelAlias || $this->with || $this->select
         || $this->selectColumns || $this->asColumns || $this->selectModifiers
         || $this->map || $this->having || $this->joins) {
            return $this->findPkComplex($key, $con);
        } else {
            return $this->findPkSimple($key, $con);
        }
    }

    /**
     * Find object by primary key using raw SQL to go fast.
     * Bypass doSelect() and the object formatter by using generated code.
     *
     * @param     mixed $key Primary key to use for the query
     * @param     PropelPDO $con A connection object
     *
     * @return   DamagesUsers A model object, or null if the key is not found
     * @throws   PropelException
     */
    protected function findPkSimple($key, $con)
    {
        $sql = 'SELECT ID, PERMISSION_ID, EMAIL, FIRST_NAME, LAST_NAME, POSITION, PHONE, PHONE_MOBILE, PHONE_FAX, PASSWORD, FORCE_PASSWORD_CHANGE, CREATED, MODIFIED FROM users WHERE ID = :p0';
        try {
            $stmt = $con->prepare($sql);
            $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
            $stmt->execute();
        } catch (Exception $e) {
            Propel::log($e->getMessage(), Propel::LOG_ERR);
            throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
        }
        $obj = null;
        if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
            $obj = new DamagesUsers();
            $obj->hydrate($row);
            DamagesUsersPeer::addInstanceToPool($obj, (string) $key);
        }
        $stmt->closeCursor();

        return $obj;
    }

    /**
     * Find object by primary key.
     *
     * @param     mixed $key Primary key to use for the query
     * @param     PropelPDO $con A connection object
     *
     * @return DamagesUsers|DamagesUsers[]|mixed the result, formatted by the current formatter
     */
    protected function findPkComplex($key, $con)
    {
        // As the query uses a PK condition, no limit(1) is necessary.
        $criteria = $this->isKeepQuery() ? clone $this : $this;
        $stmt = $criteria
            ->filterByPrimaryKey($key)
            ->doSelect($con);

        return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
    }

    /**
     * Find objects by primary key
     * <code>
     * $objs = $c->findPks(array(12, 56, 832), $con);
     * </code>
     * @param     array $keys Primary keys to use for the query
     * @param     PropelPDO $con an optional connection object
     *
     * @return PropelObjectCollection|DamagesUsers[]|mixed the list of results, formatted by the current formatter
     */
    public function findPks($keys, $con = null)
    {
        if ($con === null) {
            $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
        }
        $this->basePreSelect($con);
        $criteria = $this->isKeepQuery() ? clone $this : $this;
        $stmt = $criteria
            ->filterByPrimaryKeys($keys)
            ->doSelect($con);

        return $criteria->getFormatter()->init($criteria)->format($stmt);
    }

    /**
     * Filter the query by primary key
     *
     * @param     mixed $key Primary key to use for the query
     *
     * @return DamagesUsersQuery The current query, for fluid interface
     */
    public function filterByPrimaryKey($key)
    {

        return $this->addUsingAlias(DamagesUsersPeer::ID, $key, Criteria::EQUAL);
    }

    /**
     * Filter the query by a list of primary keys
     *
     * @param     array $keys The list of primary key to use for the query
     *
     * @return DamagesUsersQuery The current query, for fluid interface
     */
    public function filterByPrimaryKeys($keys)
    {

        return $this->addUsingAlias(DamagesUsersPeer::ID, $keys, Criteria::IN);
    }

    /**
     * Filter the query on the id column
     *
     * Example usage:
     * <code>
     * $query->filterById(1234); // WHERE id = 1234
     * $query->filterById(array(12, 34)); // WHERE id IN (12, 34)
     * $query->filterById(array('min' => 12)); // WHERE id > 12
     * </code>
     *
     * @param     mixed $id The value to use as filter.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return DamagesUsersQuery The current query, for fluid interface
     */
    public function filterById($id = null, $comparison = null)
    {
        if (is_array($id) && null === $comparison) {
            $comparison = Criteria::IN;
        }

        return $this->addUsingAlias(DamagesUsersPeer::ID, $id, $comparison);
    }

    /**
     * Filter the query on the permission_id column
     *
     * Example usage:
     * <code>
     * $query->filterByPermissionId(1234); // WHERE permission_id = 1234
     * $query->filterByPermissionId(array(12, 34)); // WHERE permission_id IN (12, 34)
     * $query->filterByPermissionId(array('min' => 12)); // WHERE permission_id > 12
     * </code>
     *
     * @see       filterByPermissions()
     *
     * @param     mixed $permissionId The value to use as filter.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return DamagesUsersQuery The current query, for fluid interface
     */
    public function filterByPermissionId($permissionId = null, $comparison = null)
    {
        if (is_array($permissionId)) {
            $useMinMax = false;
            if (isset($permissionId['min'])) {
                $this->addUsingAlias(DamagesUsersPeer::PERMISSION_ID, $permissionId['min'], Criteria::GREATER_EQUAL);
                $useMinMax = true;
            }
            if (isset($permissionId['max'])) {
                $this->addUsingAlias(DamagesUsersPeer::PERMISSION_ID, $permissionId['max'], Criteria::LESS_EQUAL);
                $useMinMax = true;
            }
            if ($useMinMax) {
                return $this;
            }
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }
        }

        return $this->addUsingAlias(DamagesUsersPeer::PERMISSION_ID, $permissionId, $comparison);
    }

    /**
     * Filter the query on the email column
     *
     * Example usage:
     * <code>
     * $query->filterByEmail('fooValue');   // WHERE email = 'fooValue'
     * $query->filterByEmail('%fooValue%'); // WHERE email LIKE '%fooValue%'
     * </code>
     *
     * @param     string $email The value to use as filter.
     *              Accepts wildcards (* and % trigger a LIKE)
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return DamagesUsersQuery The current query, for fluid interface
     */
    public function filterByEmail($email = null, $comparison = null)
    {
        if (null === $comparison) {
            if (is_array($email)) {
                $comparison = Criteria::IN;
            } elseif (preg_match('/[\%\*]/', $email)) {
                $email = str_replace('*', '%', $email);
                $comparison = Criteria::LIKE;
            }
        }

        return $this->addUsingAlias(DamagesUsersPeer::EMAIL, $email, $comparison);
    }

    /**
     * Filter the query on the first_name column
     *
     * Example usage:
     * <code>
     * $query->filterByFirstName('fooValue');   // WHERE first_name = 'fooValue'
     * $query->filterByFirstName('%fooValue%'); // WHERE first_name LIKE '%fooValue%'
     * </code>
     *
     * @param     string $firstName The value to use as filter.
     *              Accepts wildcards (* and % trigger a LIKE)
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return DamagesUsersQuery The current query, for fluid interface
     */
    public function filterByFirstName($firstName = null, $comparison = null)
    {
        if (null === $comparison) {
            if (is_array($firstName)) {
                $comparison = Criteria::IN;
            } elseif (preg_match('/[\%\*]/', $firstName)) {
                $firstName = str_replace('*', '%', $firstName);
                $comparison = Criteria::LIKE;
            }
        }

        return $this->addUsingAlias(DamagesUsersPeer::FIRST_NAME, $firstName, $comparison);
    }

    /**
     * Filter the query on the last_name column
     *
     * Example usage:
     * <code>
     * $query->filterByLastName('fooValue');   // WHERE last_name = 'fooValue'
     * $query->filterByLastName('%fooValue%'); // WHERE last_name LIKE '%fooValue%'
     * </code>
     *
     * @param     string $lastName The value to use as filter.
     *              Accepts wildcards (* and % trigger a LIKE)
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return DamagesUsersQuery The current query, for fluid interface
     */
    public function filterByLastName($lastName = null, $comparison = null)
    {
        if (null === $comparison) {
            if (is_array($lastName)) {
                $comparison = Criteria::IN;
            } elseif (preg_match('/[\%\*]/', $lastName)) {
                $lastName = str_replace('*', '%', $lastName);
                $comparison = Criteria::LIKE;
            }
        }

        return $this->addUsingAlias(DamagesUsersPeer::LAST_NAME, $lastName, $comparison);
    }

    /**
     * Filter the query on the position column
     *
     * Example usage:
     * <code>
     * $query->filterByPosition('fooValue');   // WHERE position = 'fooValue'
     * $query->filterByPosition('%fooValue%'); // WHERE position LIKE '%fooValue%'
     * </code>
     *
     * @param     string $position The value to use as filter.
     *              Accepts wildcards (* and % trigger a LIKE)
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return DamagesUsersQuery The current query, for fluid interface
     */
    public function filterByPosition($position = null, $comparison = null)
    {
        if (null === $comparison) {
            if (is_array($position)) {
                $comparison = Criteria::IN;
            } elseif (preg_match('/[\%\*]/', $position)) {
                $position = str_replace('*', '%', $position);
                $comparison = Criteria::LIKE;
            }
        }

        return $this->addUsingAlias(DamagesUsersPeer::POSITION, $position, $comparison);
    }

    /**
     * Filter the query on the phone column
     *
     * Example usage:
     * <code>
     * $query->filterByPhone('fooValue');   // WHERE phone = 'fooValue'
     * $query->filterByPhone('%fooValue%'); // WHERE phone LIKE '%fooValue%'
     * </code>
     *
     * @param     string $phone The value to use as filter.
     *              Accepts wildcards (* and % trigger a LIKE)
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return DamagesUsersQuery The current query, for fluid interface
     */
    public function filterByPhone($phone = null, $comparison = null)
    {
        if (null === $comparison) {
            if (is_array($phone)) {
                $comparison = Criteria::IN;
            } elseif (preg_match('/[\%\*]/', $phone)) {
                $phone = str_replace('*', '%', $phone);
                $comparison = Criteria::LIKE;
            }
        }

        return $this->addUsingAlias(DamagesUsersPeer::PHONE, $phone, $comparison);
    }

    /**
     * Filter the query on the phone_mobile column
     *
     * Example usage:
     * <code>
     * $query->filterByPhoneMobile('fooValue');   // WHERE phone_mobile = 'fooValue'
     * $query->filterByPhoneMobile('%fooValue%'); // WHERE phone_mobile LIKE '%fooValue%'
     * </code>
     *
     * @param     string $phoneMobile The value to use as filter.
     *              Accepts wildcards (* and % trigger a LIKE)
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return DamagesUsersQuery The current query, for fluid interface
     */
    public function filterByPhoneMobile($phoneMobile = null, $comparison = null)
    {
        if (null === $comparison) {
            if (is_array($phoneMobile)) {
                $comparison = Criteria::IN;
            } elseif (preg_match('/[\%\*]/', $phoneMobile)) {
                $phoneMobile = str_replace('*', '%', $phoneMobile);
                $comparison = Criteria::LIKE;
            }
        }

        return $this->addUsingAlias(DamagesUsersPeer::PHONE_MOBILE, $phoneMobile, $comparison);
    }

    /**
     * Filter the query on the phone_fax column
     *
     * Example usage:
     * <code>
     * $query->filterByPhoneFax('fooValue');   // WHERE phone_fax = 'fooValue'
     * $query->filterByPhoneFax('%fooValue%'); // WHERE phone_fax LIKE '%fooValue%'
     * </code>
     *
     * @param     string $phoneFax The value to use as filter.
     *              Accepts wildcards (* and % trigger a LIKE)
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return DamagesUsersQuery The current query, for fluid interface
     */
    public function filterByPhoneFax($phoneFax = null, $comparison = null)
    {
        if (null === $comparison) {
            if (is_array($phoneFax)) {
                $comparison = Criteria::IN;
            } elseif (preg_match('/[\%\*]/', $phoneFax)) {
                $phoneFax = str_replace('*', '%', $phoneFax);
                $comparison = Criteria::LIKE;
            }
        }

        return $this->addUsingAlias(DamagesUsersPeer::PHONE_FAX, $phoneFax, $comparison);
    }

    /**
     * Filter the query on the password column
     *
     * Example usage:
     * <code>
     * $query->filterByPassword('fooValue');   // WHERE password = 'fooValue'
     * $query->filterByPassword('%fooValue%'); // WHERE password LIKE '%fooValue%'
     * </code>
     *
     * @param     string $password The value to use as filter.
     *              Accepts wildcards (* and % trigger a LIKE)
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return DamagesUsersQuery The current query, for fluid interface
     */
    public function filterByPassword($password = null, $comparison = null)
    {
        if (null === $comparison) {
            if (is_array($password)) {
                $comparison = Criteria::IN;
            } elseif (preg_match('/[\%\*]/', $password)) {
                $password = str_replace('*', '%', $password);
                $comparison = Criteria::LIKE;
            }
        }

        return $this->addUsingAlias(DamagesUsersPeer::PASSWORD, $password, $comparison);
    }

    /**
     * Filter the query on the force_password_change column
     *
     * Example usage:
     * <code>
     * $query->filterByForcePasswordChange(1234); // WHERE force_password_change = 1234
     * $query->filterByForcePasswordChange(array(12, 34)); // WHERE force_password_change IN (12, 34)
     * $query->filterByForcePasswordChange(array('min' => 12)); // WHERE force_password_change > 12
     * </code>
     *
     * @param     mixed $forcePasswordChange The value to use as filter.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return DamagesUsersQuery The current query, for fluid interface
     */
    public function filterByForcePasswordChange($forcePasswordChange = null, $comparison = null)
    {
        if (is_array($forcePasswordChange)) {
            $useMinMax = false;
            if (isset($forcePasswordChange['min'])) {
                $this->addUsingAlias(DamagesUsersPeer::FORCE_PASSWORD_CHANGE, $forcePasswordChange['min'], Criteria::GREATER_EQUAL);
                $useMinMax = true;
            }
            if (isset($forcePasswordChange['max'])) {
                $this->addUsingAlias(DamagesUsersPeer::FORCE_PASSWORD_CHANGE, $forcePasswordChange['max'], Criteria::LESS_EQUAL);
                $useMinMax = true;
            }
            if ($useMinMax) {
                return $this;
            }
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }
        }

        return $this->addUsingAlias(DamagesUsersPeer::FORCE_PASSWORD_CHANGE, $forcePasswordChange, $comparison);
    }

    /**
     * Filter the query on the created column
     *
     * Example usage:
     * <code>
     * $query->filterByCreated('2011-03-14'); // WHERE created = '2011-03-14'
     * $query->filterByCreated('now'); // WHERE created = '2011-03-14'
     * $query->filterByCreated(array('max' => 'yesterday')); // WHERE created > '2011-03-13'
     * </code>
     *
     * @param     mixed $created The value to use as filter.
     *              Values can be integers (unix timestamps), DateTime objects, or strings.
     *              Empty strings are treated as NULL.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return DamagesUsersQuery The current query, for fluid interface
     */
    public function filterByCreated($created = null, $comparison = null)
    {
        if (is_array($created)) {
            $useMinMax = false;
            if (isset($created['min'])) {
                $this->addUsingAlias(DamagesUsersPeer::CREATED, $created['min'], Criteria::GREATER_EQUAL);
                $useMinMax = true;
            }
            if (isset($created['max'])) {
                $this->addUsingAlias(DamagesUsersPeer::CREATED, $created['max'], Criteria::LESS_EQUAL);
                $useMinMax = true;
            }
            if ($useMinMax) {
                return $this;
            }
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }
        }

        return $this->addUsingAlias(DamagesUsersPeer::CREATED, $created, $comparison);
    }

    /**
     * Filter the query on the modified column
     *
     * Example usage:
     * <code>
     * $query->filterByModified('2011-03-14'); // WHERE modified = '2011-03-14'
     * $query->filterByModified('now'); // WHERE modified = '2011-03-14'
     * $query->filterByModified(array('max' => 'yesterday')); // WHERE modified > '2011-03-13'
     * </code>
     *
     * @param     mixed $modified The value to use as filter.
     *              Values can be integers (unix timestamps), DateTime objects, or strings.
     *              Empty strings are treated as NULL.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return DamagesUsersQuery The current query, for fluid interface
     */
    public function filterByModified($modified = null, $comparison = null)
    {
        if (is_array($modified)) {
            $useMinMax = false;
            if (isset($modified['min'])) {
                $this->addUsingAlias(DamagesUsersPeer::MODIFIED, $modified['min'], Criteria::GREATER_EQUAL);
                $useMinMax = true;
            }
            if (isset($modified['max'])) {
                $this->addUsingAlias(DamagesUsersPeer::MODIFIED, $modified['max'], Criteria::LESS_EQUAL);
                $useMinMax = true;
            }
            if ($useMinMax) {
                return $this;
            }
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }
        }

        return $this->addUsingAlias(DamagesUsersPeer::MODIFIED, $modified, $comparison);
    }

    /**
     * Filter the query by a related DamagesPermissions object
     *
     * @param   DamagesPermissions|PropelObjectCollection $permissions The related object(s) to use as filter
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return   DamagesUsersQuery The current query, for fluid interface
     * @throws   PropelException - if the provided filter is invalid.
     */
    public function filterByPermissions($permissions, $comparison = null)
    {
        if ($permissions instanceof DamagesPermissions) {
            return $this
                ->addUsingAlias(DamagesUsersPeer::PERMISSION_ID, $permissions->getId(), $comparison);
        } elseif ($permissions instanceof PropelObjectCollection) {
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }

            return $this
                ->addUsingAlias(DamagesUsersPeer::PERMISSION_ID, $permissions->toKeyValue('PrimaryKey', 'Id'), $comparison);
        } else {
            throw new PropelException('filterByPermissions() only accepts arguments of type DamagesPermissions or PropelCollection');
        }
    }

    /**
     * Adds a JOIN clause to the query using the Permissions relation
     *
     * @param     string $relationAlias optional alias for the relation
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return DamagesUsersQuery The current query, for fluid interface
     */
    public function joinPermissions($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    {
        $tableMap = $this->getTableMap();
        $relationMap = $tableMap->getRelation('Permissions');

        // create a ModelJoin object for this join
        $join = new ModelJoin();
        $join->setJoinType($joinType);
        $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
        if ($previousJoin = $this->getPreviousJoin()) {
            $join->setPreviousJoin($previousJoin);
        }

        // add the ModelJoin to the current object
        if ($relationAlias) {
            $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
            $this->addJoinObject($join, $relationAlias);
        } else {
            $this->addJoinObject($join, 'Permissions');
        }

        return $this;
    }

    /**
     * Use the Permissions relation Permissions object
     *
     * @see       useQuery()
     *
     * @param     string $relationAlias optional alias for the relation,
     *                                   to be used as main alias in the secondary query
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return   DamagesPermissionsQuery A secondary query class using the current class as primary query
     */
    public function usePermissionsQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    {
        return $this
            ->joinPermissions($relationAlias, $joinType)
            ->useQuery($relationAlias ? $relationAlias : 'Permissions', 'DamagesPermissionsQuery');
    }

    /**
     * Filter the query by a related DamagesSessions object
     *
     * @param   DamagesSessions|PropelObjectCollection $sessions  the related object to use as filter
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return   DamagesUsersQuery The current query, for fluid interface
     * @throws   PropelException - if the provided filter is invalid.
     */
    public function filterBySessions($sessions, $comparison = null)
    {
        if ($sessions instanceof DamagesSessions) {
            return $this
                ->addUsingAlias(DamagesUsersPeer::ID, $sessions->getUserId(), $comparison);
        } elseif ($sessions instanceof PropelObjectCollection) {
            return $this
                ->useSessionsQuery()
                ->filterByPrimaryKeys($sessions->getPrimaryKeys())
                ->endUse();
        } else {
            throw new PropelException('filterBySessions() only accepts arguments of type DamagesSessions or PropelCollection');
        }
    }

    /**
     * Adds a JOIN clause to the query using the Sessions relation
     *
     * @param     string $relationAlias optional alias for the relation
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return DamagesUsersQuery The current query, for fluid interface
     */
    public function joinSessions($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    {
        $tableMap = $this->getTableMap();
        $relationMap = $tableMap->getRelation('Sessions');

        // create a ModelJoin object for this join
        $join = new ModelJoin();
        $join->setJoinType($joinType);
        $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
        if ($previousJoin = $this->getPreviousJoin()) {
            $join->setPreviousJoin($previousJoin);
        }

        // add the ModelJoin to the current object
        if ($relationAlias) {
            $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
            $this->addJoinObject($join, $relationAlias);
        } else {
            $this->addJoinObject($join, 'Sessions');
        }

        return $this;
    }

    /**
     * Use the Sessions relation Sessions object
     *
     * @see       useQuery()
     *
     * @param     string $relationAlias optional alias for the relation,
     *                                   to be used as main alias in the secondary query
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return   DamagesSessionsQuery A secondary query class using the current class as primary query
     */
    public function useSessionsQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    {
        return $this
            ->joinSessions($relationAlias, $joinType)
            ->useQuery($relationAlias ? $relationAlias : 'Sessions', 'DamagesSessionsQuery');
    }

    /**
     * Filter the query by a related DamagesCarDamages object
     *
     * @param   DamagesCarDamages|PropelObjectCollection $carDamages  the related object to use as filter
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return   DamagesUsersQuery The current query, for fluid interface
     * @throws   PropelException - if the provided filter is invalid.
     */
    public function filterByCarDamagesRelatedByLsId($carDamages, $comparison = null)
    {
        if ($carDamages instanceof DamagesCarDamages) {
            return $this
                ->addUsingAlias(DamagesUsersPeer::ID, $carDamages->getLsId(), $comparison);
        } elseif ($carDamages instanceof PropelObjectCollection) {
            return $this
                ->useCarDamagesRelatedByLsIdQuery()
                ->filterByPrimaryKeys($carDamages->getPrimaryKeys())
                ->endUse();
        } else {
            throw new PropelException('filterByCarDamagesRelatedByLsId() only accepts arguments of type DamagesCarDamages or PropelCollection');
        }
    }

    /**
     * Adds a JOIN clause to the query using the CarDamagesRelatedByLsId relation
     *
     * @param     string $relationAlias optional alias for the relation
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return DamagesUsersQuery The current query, for fluid interface
     */
    public function joinCarDamagesRelatedByLsId($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
    {
        $tableMap = $this->getTableMap();
        $relationMap = $tableMap->getRelation('CarDamagesRelatedByLsId');

        // create a ModelJoin object for this join
        $join = new ModelJoin();
        $join->setJoinType($joinType);
        $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
        if ($previousJoin = $this->getPreviousJoin()) {
            $join->setPreviousJoin($previousJoin);
        }

        // add the ModelJoin to the current object
        if ($relationAlias) {
            $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
            $this->addJoinObject($join, $relationAlias);
        } else {
            $this->addJoinObject($join, 'CarDamagesRelatedByLsId');
        }

        return $this;
    }

    /**
     * Use the CarDamagesRelatedByLsId relation CarDamages object
     *
     * @see       useQuery()
     *
     * @param     string $relationAlias optional alias for the relation,
     *                                   to be used as main alias in the secondary query
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return   DamagesCarDamagesQuery A secondary query class using the current class as primary query
     */
    public function useCarDamagesRelatedByLsIdQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
    {
        return $this
            ->joinCarDamagesRelatedByLsId($relationAlias, $joinType)
            ->useQuery($relationAlias ? $relationAlias : 'CarDamagesRelatedByLsId', 'DamagesCarDamagesQuery');
    }

    /**
     * Filter the query by a related DamagesCarDamages object
     *
     * @param   DamagesCarDamages|PropelObjectCollection $carDamages  the related object to use as filter
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return   DamagesUsersQuery The current query, for fluid interface
     * @throws   PropelException - if the provided filter is invalid.
     */
    public function filterByCarDamagesRelatedByOlId($carDamages, $comparison = null)
    {
        if ($carDamages instanceof DamagesCarDamages) {
            return $this
                ->addUsingAlias(DamagesUsersPeer::ID, $carDamages->getOlId(), $comparison);
        } elseif ($carDamages instanceof PropelObjectCollection) {
            return $this
                ->useCarDamagesRelatedByOlIdQuery()
                ->filterByPrimaryKeys($carDamages->getPrimaryKeys())
                ->endUse();
        } else {
            throw new PropelException('filterByCarDamagesRelatedByOlId() only accepts arguments of type DamagesCarDamages or PropelCollection');
        }
    }

    /**
     * Adds a JOIN clause to the query using the CarDamagesRelatedByOlId relation
     *
     * @param     string $relationAlias optional alias for the relation
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return DamagesUsersQuery The current query, for fluid interface
     */
    public function joinCarDamagesRelatedByOlId($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
    {
        $tableMap = $this->getTableMap();
        $relationMap = $tableMap->getRelation('CarDamagesRelatedByOlId');

        // create a ModelJoin object for this join
        $join = new ModelJoin();
        $join->setJoinType($joinType);
        $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
        if ($previousJoin = $this->getPreviousJoin()) {
            $join->setPreviousJoin($previousJoin);
        }

        // add the ModelJoin to the current object
        if ($relationAlias) {
            $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
            $this->addJoinObject($join, $relationAlias);
        } else {
            $this->addJoinObject($join, 'CarDamagesRelatedByOlId');
        }

        return $this;
    }

    /**
     * Use the CarDamagesRelatedByOlId relation CarDamages object
     *
     * @see       useQuery()
     *
     * @param     string $relationAlias optional alias for the relation,
     *                                   to be used as main alias in the secondary query
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return   DamagesCarDamagesQuery A secondary query class using the current class as primary query
     */
    public function useCarDamagesRelatedByOlIdQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
    {
        return $this
            ->joinCarDamagesRelatedByOlId($relationAlias, $joinType)
            ->useQuery($relationAlias ? $relationAlias : 'CarDamagesRelatedByOlId', 'DamagesCarDamagesQuery');
    }

    /**
     * Filter the query by a related DamagesUserDealers object
     *
     * @param   DamagesUserDealers|PropelObjectCollection $userDealers  the related object to use as filter
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return   DamagesUsersQuery The current query, for fluid interface
     * @throws   PropelException - if the provided filter is invalid.
     */
    public function filterByUserDealers($userDealers, $comparison = null)
    {
        if ($userDealers instanceof DamagesUserDealers) {
            return $this
                ->addUsingAlias(DamagesUsersPeer::ID, $userDealers->getUserId(), $comparison);
        } elseif ($userDealers instanceof PropelObjectCollection) {
            return $this
                ->useUserDealersQuery()
                ->filterByPrimaryKeys($userDealers->getPrimaryKeys())
                ->endUse();
        } else {
            throw new PropelException('filterByUserDealers() only accepts arguments of type DamagesUserDealers or PropelCollection');
        }
    }

    /**
     * Adds a JOIN clause to the query using the UserDealers relation
     *
     * @param     string $relationAlias optional alias for the relation
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return DamagesUsersQuery The current query, for fluid interface
     */
    public function joinUserDealers($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    {
        $tableMap = $this->getTableMap();
        $relationMap = $tableMap->getRelation('UserDealers');

        // create a ModelJoin object for this join
        $join = new ModelJoin();
        $join->setJoinType($joinType);
        $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
        if ($previousJoin = $this->getPreviousJoin()) {
            $join->setPreviousJoin($previousJoin);
        }

        // add the ModelJoin to the current object
        if ($relationAlias) {
            $this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
            $this->addJoinObject($join, $relationAlias);
        } else {
            $this->addJoinObject($join, 'UserDealers');
        }

        return $this;
    }

    /**
     * Use the UserDealers relation UserDealers object
     *
     * @see       useQuery()
     *
     * @param     string $relationAlias optional alias for the relation,
     *                                   to be used as main alias in the secondary query
     * @param     string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
     *
     * @return   DamagesUserDealersQuery A secondary query class using the current class as primary query
     */
    public function useUserDealersQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
    {
        return $this
            ->joinUserDealers($relationAlias, $joinType)
            ->useQuery($relationAlias ? $relationAlias : 'UserDealers', 'DamagesUserDealersQuery');
    }

    /**
     * Exclude object from result
     *
     * @param   DamagesUsers $users Object to remove from the list of results
     *
     * @return DamagesUsersQuery The current query, for fluid interface
     */
    public function prune($users = null)
    {
        if ($users) {
            $this->addUsingAlias(DamagesUsersPeer::ID, $users->getId(), Criteria::NOT_EQUAL);
        }

        return $this;
    }

}
